<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registration Form</title>

<style type="text/css">
body {
	font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;
	font-size:12px;
}

fieldset {
	background:#EBF4FB none repeat scroll 0 0;
	border:2px solid #B7DDF2;
	width: 500px;
}
legend {
	color: #fff;
	background: #80D3E2;
	border: 1px solid #781351;
	padding: 2px 6px
}

p {
	border-bottom:1px solid #B7DDF2;
	color:#666666;
	font-size:11px;
	margin-bottom:20px;
	padding-bottom:10px;
}

a{
    color:#0099FF;
font-weight:bold;
}

/* Box Style */


 .success, .warning, .errormsgbox, .validation {
	border: 1px solid;
	margin: 0 auto;
	padding:10px 5px 10px 50px;
	background-repeat: no-repeat;
	background-position: 10px center;
     font-weight:bold;
     width:450px;
     
}

.success {
   
	color: #4F8A10;
	background-color: #DFF2BF;
	background-image:url('img/success.png');
}

.errormsgbox {
 
	color: #D8000C;
	background-color: #FFBABA;
	background-image: url('img/error.png');
	
}

</style>

</head>
<body>

	<?php
		session_start();
		include ('database_connect.php');
		include ('mysqlfunctions.php');

		$username = $_POST['myusername'];
		$validation= $_POST['myvalidation'];
                //echo $validation;


		$sql="SELECT * FROM member WHERE username ='$username' AND validation ='$validation'";// (username='$username' AND validation='$validation')" ;
		$result=mysql_query($sql);

		if(mysql_num_rows($result) == 1) {
			
    // query database

    $sql2="UPDATE member  SET verified = '1' WHERE username ='$username'";
    //echo $sql; //testing
  	$result=mysql_query($sql2); 
			echo "<center><fieldset>
					<legend>Notice</legend>
						<div class=\"success\">
						<strong>Account Created. </strong><br>
						Welcome to UH Bookselling! Now you will be able to sell and buy books from other students. <br>
						Please wait while you are redirected to the main page. Thank you!
						</div>
				</fieldset></center>";
			header("refresh:5;url=index.php");
		}

		else {
			echo "<center><fieldset>
					<legend>Notice</legend>
						<div class=\"errormsgbox\">
						<strong>Account Not Created. </strong><br>
						Username or Account Verification is incorrect. 
						</div>
				</fieldset></center>";
			header("refresh:5;url=authentication.php");
		}
	?>
</body>
</html>